package com.yc.bigdata.kafka.controller;

import com.yc.bigdata.common.dto.DemoMsg;
import com.yc.bigdata.common.vo.ResultBody;
import com.yc.bigdata.kafka.service.TestProduceService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p></p>
 *
 * @author: YuanChilde
 * @date: 2020-02-11 8:52
 * @version: 1.0
 * Modification History:
 * Date    Author      Version     Description
 * -----------------------------------------------------------------
 * 2020-02-11 8:52    YuanChilde     1.0        新增
 */
@RestController
@RequestMapping(value = "/test", method = {RequestMethod.POST}, produces = {"application/json"})
public class TestController {
    @Autowired
    private TestProduceService testProduceService;

    @RequestMapping(value = "/send")
    public ResultBody send(@RequestParam("message") String message) {
        DemoMsg demoMsg = DemoMsg.builder()
                .message(message)
                .timestamp(System.currentTimeMillis())
                .build();
        testProduceService.sendMessage(demoMsg);
        return ResultBody.ok();
    }
}
